package com.school.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import com.school.entity.News;

public class AttendanceManagerDaoImpl implements  AttendanceManagerDao{

	@Override
	public ArrayList<String> getAllClass() {
		Connection c = null;
		ResultSet rs = null;
		System.out.println("inside class");
		ArrayList<String> classes = new ArrayList<String>();
		try {
			
			c = ConnectionUtil.getConnection();
			String q1 = "SELECT * FROM classes";
			PreparedStatement s = c.prepareStatement(q1);
			rs = s.executeQuery();
			
			while (rs.next()) {
				classes.add(rs.getString(1));
			}
			rs = null;
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		finally{
			ConnectionUtil.CloseDbResources(c);
		}
		return classes;
	}

	@Override
	public ArrayList<String> getAllSection() {
		Connection c = null;
		ResultSet rs = null;
		
		ArrayList<String> sections = new ArrayList<String>();
		try {
			
			c = ConnectionUtil.getConnection();
			String q1 = "SELECT * FROM sections";
			PreparedStatement s = c.prepareStatement(q1);
			rs = s.executeQuery();
			
			while (rs.next()) {
				sections.add(rs.getString(1));
			}
			rs = null;
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		finally{
			ConnectionUtil.CloseDbResources(c);
		}
		return sections;
	}

}
